import type { RouteRecordRaw } from 'vue-router';
export const routesArr: RouteRecordRaw[] = [
	{
		component: () => import('@/layout/index.vue'),
		path: '/',
		name: 'layout',
		redirect: '/home',
		children: [
			{
				component: import('@/views/home/index.vue'),
				path: '/home',
				name: 'home',
				meta: {
					title: '首页',
					hidden: false,
					icon: 'HomeFilled',
				},
			},
		],
		meta: {
			title: 'layout',
			hidden: false,
		},
	},
	{
		component: () => import('@/views/screen/index.vue'),
		path: '/screen',
		name: 'screen',
		meta: {
			hidden: false,
			title: '数据大屏',
			icon: 'Platform',
		},
	},
	{
		component: () => import('@/layout/index.vue'),
		path: '/permission',
		name: 'permission',
		redirect:"/permission/user",
		meta: {
			hidden: false,
			title: '权限管理',
			icon: 'Stamp',
		},
		children: [
			{
				component: () => import('@/views/permission/user/index.vue'),
				path: '/permission/user',
				name: 'user',
				meta: {
					hidden: false,
					title: '用户管理',
					icon: 'UserFilled',
				},
			},
			{
				component: () => import('@/views/permission/role/index.vue'),
				path: '/permission/role',
				name: 'role',
				meta: {
					hidden: false,
					title: '角色管理',
					icon: 'Avatar',
				},
			},
			{
				component: () => import('@/views/permission/menu/index.vue'),
				path: '/permission/menu',
				name: 'menu',
				meta: {
					hidden: false,
					title: '菜单管理',
					icon: 'Grid',
				},
			},
		],
	},
	{
		component: () => import('@/layout/index.vue'),
		path: '/product',
		name: 'product',
		redirect:'/product/trademark',
		meta: {
			hidden: false,
			title: '商品管理',
			icon: 'Shop',
		},
		children: [
			{
				component: () => import('@/views/product/trademark/index.vue'),
				path: '/product/trademark',
				name: 'trademark',
				meta: {
					hidden: false,
					title: '品牌管理',
					icon: 'Flag',
				},
			},
			{
				component: () => import('@/views/product/attr/index.vue'),
				path: '/product/attr',
				name: 'attr',
				meta: {
					hidden: false,
					title: '属性管理',
					icon: 'Ticket',
				},
			},
			{
				component: () => import('@/views/product/spu/index.vue'),
				path: '/product/spu',
				name: 'spu',
				meta: {
					hidden: false,
					title: 'SPU管理',
					icon: 'Basketball',
				},
			},
			{
				component: () => import('@/views/product/sku/index.vue'),
				path: '/product/sku',
				name: 'sku',
				meta: {
					hidden: false,
					title: 'SKU管理',
					icon: 'GoodsFilled',
				},
			},
		],
	},
	{
		component: () => import('@/views/login/index.vue'),
		path: '/login',
		name: 'login',
		meta: {
			hidden: true,
		},
	},
	{
		component: () => import('@/views/404/index.vue'),
		path: '/:pathMatch(.*)*',
		name: '404',
		meta: {
			hidden: true,
		},
	},
];
/**
 * 过滤出需要隐藏的routes
 * @param routes 需要过滤的route
 * @returns 过滤后的route数组
 */
let filterRoutes = (routes: RouteRecordRaw[]): RouteRecordRaw[] => {
	return routes.filter((route) => {
		if (route.children) {
			route.children = filterRoutes(route.children);
		}
		return !route.meta?.hidden;
	});
};
// 已经过滤完毕的routes
export let filtedRoutesArr = filterRoutes(routesArr);
